package edu.nf.takeoutdemo.model.converter;

import edu.nf.takeoutdemo.model.dto.CategoryDTO;
import edu.nf.takeoutdemo.model.entity.Category;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 *
 * @author zjl
 * @date 2025/10/25
 */
@Mapper(componentModel = "spring")
public interface CategoryConverter {

    @Mappings({
            @Mapping(source = "id",target = "id"),
            @Mapping(source = "type",target = "type"),
            @Mapping(source = "name",target = "name"),
            @Mapping(source = "sort",target = "sort")
    })
    CategoryDTO toCategoryDTO(Category category);

    @InheritInverseConfiguration(name = "toCategoryDTO")
    Category toCategory(CategoryDTO categoryDTO);
}
